package com.queclink.ycm.entity.data;

import com.alibaba.fastjson.JSONObject;
import com.queclink.ycm.common.utils.HexUtils;


/**
 * @author jim.li
 * @email jim.li@queclink.com
 * @date 2021-12-24 17:30:00
 */
public class Data87 extends Data {

    private String ConnectionStatus;
    private String Voltage;

    public Data87() {
    }

    public String getConnectionStatus(JSONObject jsonObject) {
        Integer connectionStatus = jsonObject.getInteger("ConnectionStatus");
        return HexUtils.intToHex(connectionStatus, 2);
    }

    public String getVoltage(JSONObject jsonObject) {
        Integer voltage = jsonObject.getInteger("Voltage");
        return HexUtils.intToHex(voltage, 4);
    }


    public String getDataID() {
        // data87
        return HexUtils.intToHex(87, 2);
    }

    public String getLength() {
        return "03";
    }

    @Override
    public String combine(JSONObject jsonObject) throws Exception {
        StringBuffer sb = new StringBuffer();
        sb.append(this.getDataID());
        sb.append(this.getLength());
        sb.append(this.getConnectionStatus(jsonObject));
        sb.append(this.getVoltage(jsonObject));
        return sb.toString();
    }

}
